const imgList = document.querySelectorAll('img');

const callback = entries => {
    entries.forEach(entry => {
        if (entry.isIntersecting) {
            const image = entry.target;
            const data_src = image.getAttribute('data-src');
            image.setAttribute('src', data_src);
            observer.unobserve(image);
            console.log('触发了');
        }
    });
};

const observer = new IntersectionObserver(callback);

imgList.forEach(img => {
    observer.observe(img);
});